from fastapi import APIRouter

router = APIRouter(prefix='/dashboard', tags=['仪表板'])

@router.get("/statistics")
async def get_statistics():
    """获取统计数据"""
    return {
        "total_users": 100,
        "active_users": 85,
        "new_users_today": 5,
        "system_status": "正常",
    }


@router.get("/charts/data")
async def get_chart_data(
        chart_type: str = "line"
):
    """获取图表数据"""
    if chart_type == "line":
        return {
            "title": "用户访问趋势",
            "labels": ["周一","周二","周三","周四","周五","周六","周日"],
            "data": [100, 120, 180, 200, 160, 120, 80],
        }
    elif chart_type == "bar":
        return {
            "title": "产品销售统计",
            "labels": ["产品A", "产品B", "产品C", "产品D"],
            "data": [25, 35, 15, 25]
        }
    elif chart_type == "pie":
        return {
            "title": "用户分布",
            "labels": ["活跃用户", "非活跃用户", "新用户"],
            "data": [70, 20, 10]
        }
    else:
        return {
            "title": "默认图表",
            "labels": ["类别1", "类别2", "类别3"],
            "data": [300, 50, 100]
        }

